<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>故障分析(历史)</title>
	<meta name="viewport"  content="width=device-width, initial-scale=1">
	<link rel="stylesheet" type="text/css" href="${path}/resource/plugins/bootstrap/css/bootstrap.min.css">
  	<link rel="stylesheet" type="text/css" href="${path}/resource/css/ysrmain.css">
	<link rel="stylesheet" href="${path}/resource/css/gzfx.css">
	
	<script src="${path}/resource/plugins/jQuery/jquery-2.2.3.min.js"></script>
	<script type="text/javascript" src="${path}/resource/plugins/bootstrap/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="${path}/resource/js/echarts.min.js"></script>
	
	<script type="text/javascript"></script>
	<style>
	.main-img{padding-top:2%}
		.now-error{border-top-left-radius: 5px;border-bottom-left-radius: 5px;color:#fff;border:1px solid #3399b7;padding:4px 10px;z-index: 1000;display: inline-block;background:linear-gradient(to bottom, rgba(4, 188, 236, 0.6) 0%,rgba(255, 255, 255, 0.1) 50%,rgba(255, 255, 255, 0) 51%,rgba(4, 188, 236, 0.6) 100%)}
		.history-error{border-top-right-radius: 5px;border-bottom-right-radius: 5px;color:#fff;padding:4px 10px;border:1px solid #3399b7}
	.right-content{
		background: none;
	   	border:none;
	    box-shadow: none;
	}	
	/*底部表格*/
	.gzpd{display:table;height:calc(100% - 25px);width:100%;padding:0 10px;color:#ade8f9}
		.gzpd-img{display:table-cell;text-align:center;vertical-align: middle;}
			.gzpd-img>img{border-radius:50%;width:70px;height:70px}
		.gzpd-msg{display:table-cell;text-align:center;vertical-align: middle;width:80%;background:url(${path}/resource/images/gzpd.png);background-size:100% 100%;}
			.gzpd-msg>div{ width: 100%;height: 100%; padding: 1.1rem 30px;text-align:left;letter-spacing: 2px;flex-direction: column;align-items: flex-start;justify-content: space-between;display: flex;}
				.gzpd-msg>div>div{padding:2px;border-bottom:1px solid #31708f;width:100%}
	.gzjj{display:table;height:calc(100% - 25px);width:100%;padding:0 10px;color:#ade8f9}
	.gzjj>div{display:table-cell;text-align:center;vertical-align: middle;}
		.gzjj-img img{width:70px;}
		.gz-msg1,.gz-msg2,.gz-msg3{width:23%}
		.border-top1{border-top:3px solid #7bc758}
		.border-top2{border-top:3px solid #2488f2}
		.border-top3{border-top:3px solid #297aae}
		.fxtime{background:url(${path}/resource/images/fssj.png);background-size:100% 100%;height:50px;width:80%;margin:auto;padding:5px;padding-top: 10px;}
		.jjtime{background:url(${path}/resource/images/jjsj.png);background-size:100% 100%;height:50px;width:80%;margin:auto;padding:5px;padding-top: 10px;}
		.wcl{background:url(${path}/resource/images/wcl.png);background-size:100% 100%;height:50px;width:80%;margin:auto;padding:5px;padding-top: 10px;}
	.progress{border-radius:0;background:none;border: 1px solid #3399b7;   height: 11px;margin-bottom:5px}
	.progress-bar{background-color: #3399b7;}
	.progress:nth-child(1){background:#fff}
	/*search*/
	.search-span{background: linear-gradient(to bottom, #337ab7 0%,rgba(255, 255, 255, 0.1) 51%,rgb(128, 209, 238) 100%);
   				border-top-right-radius: 5px;
   				border-bottom-right-radius: 5px;}
   				
   	/*弹窗*/
	.layer{position:absolute;top:0;width:100%;height:100%;left:0;background:url(${path}/resource/images/qbsbbg.png);background-size:100% 100%;z-index:100;display:none}
		.layer-bg{position:absolute;width:50%;height:500px;top:0;bottom:0;left:0;right:0;margin:auto;color:#fff;}				
	       .layer-head{border: 1px solid #337ab7;letter-spacing: 3px;color:#fff;height:50px;line-height:50px;font-size:2rem;padding:0 30px;border-top-right-radius: 5px;border-top-left-radius: 5px;}
		   		.layer-head::after{top:20px}
		   		.layer-head>a{cursor: pointer;height: 30px;display: inline-block;width: 40px;text-align: center;float: right;position: relative;right: -10px;top: 11px;line-height: 25px;font-size: 25px;}
		   		.layer-head>a:hover{color:#3399b7;}
		   .layer-body{border: 1px solid #337ab7;padding:30px 40px;height:90%;border-bottom-right-radius: 5px;border-bottom-left-radius: 5px;color:#333;background: rgba(238, 238, 238, 0.3);}
				.layer-msg{width:50%;float:left;height:95%;border-right: 2px solid #3399b7;}
				.layer-analyse{width:50%;float:right;height:100%;}
			 		.analyse-img{margin:10px;height:50%;border-bottom:2px dotted #3399b7}
			 	    .analyse-span{margin:10px;height:40%;}
	.main-table .btn-a{    border: none;
    background: #6D96C9;
    color: #fff;
    border-radius: 3px;
    margin-right: 10px;
    padding:1px 4px} 
	</style>
</head>
<body>
	<!-- 头部 -->
	<!-- 开始 -->
	<jsp:include page="top_nav.jsp"></jsp:include>
	<!-- 头部结束 -->
    <!-- 右侧内容区域 -->
    <div class="right-content container-fluid ">
    	<div class="row">
    		<!-- 主要图表区域 -->
	    	<div class="main-data col-xs-9">
	    		<!--头部nav-->
	    		<div class="row right-nav">
	    			<div class=" center" style="padding-right:40px">
	    				<a class="color-m1" href="${path}/manage/redirect/allEquip/allEquipList">
	    					<img src="${path}/resource/images/back3.png">
	    				</a>
	    			</div>
	    			<div class=" center nav-hover">
	    				<a class="color-m1" href="${path}/manage/redirect/allEquip/nowEquip?serialNum=${serialNum}">
	    				<img src="${path}/resource/images/sssj3.png">
	    				运行状态
	    				</a>
	    			</div>
	    			<div class=" center nav-select">
	    				<a class="color-m2" href="${path}/manage/redirect/allEquip/faultAnalysis?serialNum=${serialNum}">
	    				<img src="${path}/resource/images/gzfx4.png">
	    				故障分析
	    				</a>
	    			</div>
	    			<div class=" center nav-hover">
	    				<a class="color-m1" href="${path}/manage/redirect/allEquip/energyEfficiency?serialNum=${serialNum}">
	    				<img src="${path}/resource/images/nxgl3.png">
	    				能效分析
	    				</a>
	    			</div>
	    			<div class=" center nav-hover">
	    				<a class="color-m1" href="${path}/manage/redirect/allEquip/healthControl?serialNum=${serialNum}">
	    				<img src="${path}/resource/images/jkgl3.png">
	    				健康管理
	    				</a>
	    			</div>
	    			<div class=" center nav-hover">
	    				<a class="color-m1" href="${path}/manage/redirect/allEquip/historyEquip?serialNum=${serialNum}">
	    				<img src="${path}/resource/images/lssj3.png">
	    				历史数据
	    				</a>
	    			</div>
	    			
	    			<div class=" right nav-over padding-r-1">	    				
	    				<div class="color-w">当前设备:${serialNum}</div>
	    			</div>
	    			
	    		</div>
	    		<!-- 主图表 -->
	    		<div class="main-img main-table">
	    			<!-- <div id="echarts1" style="width: 50%; height: 100%; float: left;"></div>
	    			<div id="echarts2" style="width: 50%; height: 100%; float: left;"></div> -->
	    			<a class="now-error" href="${path}/manage/redirect/allEquip/faultAnalysis?serialNum=${serialNum}">当前故障</a><a class="history-error" href="javascript:void(0)">历史故障</a><br>
	    			<table id="hisErrorList" class="table text-center table-striped">
	    				<tr>
	    					<th>序号</th>
	    					<th>故障时间</th>
	    					<th>故障代码</th>
	    					<th>故障描述</th>
	    					<th>故障录波</th>
	    				</tr>
	    				<tr>
	    					<td>1</td>
	    					<td>2016-11-25 20:18:20</td>
	    					<td>F1</td>
	    					<td>485通讯故障</td>
	    					<td><button>查看</button><button>下载</button></td>
	    				</tr>
	    				<tr>
	    					<td>2</td>
	    					<td>2016-11-20 12:18:25</td>
	    					<td>F112</td>
	    					<td>逆变脉冲综合使能故障</td>
	    					<td><button>查看</button><button>下载</button></td>
	    				</tr>
	    				<tr>
	    					<td>3</td>
	    					<td>2016-10-24 23:35:12</td>
	    					<td>F115</td>
	    					<td>整流脉冲收使能故障</td>
	    					<td><button>查看</button><button>下载</button></td>
	    				</tr>
	    				<tr>
	    					<td>4</td>
	    					<td>2016-10-12 11:48:52</td>
	    					<td>F16</td>
	    					<td>风机接触器无法闭合</td>
	    					<td><button>查看</button><button>下载</button></td>
	    				</tr>
	    				<tr>
	    					<td>5</td>
	    					<td>2016-09-22 22:17:36</td>
	    					<td>F19</td>
	    					<td>接地检测保护设置错误</td>
	    					<td><button>查看</button><button>下载</button></td>
	    				</tr>
	    				<tr>
	    					<td>6</td>
	    					<td>2016-08-25 09:34:20</td>
	    					<td>F24</td>
	    					<td>逆变模块C相上管保护</td>
	    					<td><button>查看</button><button>下载</button></td>
	    				</tr>
	    			</table>
	    			<div id="fenye" class="pagers falut-pagers">
					  	<nav class="float-r ">
					  	  <ul class="pagination">
					  	    <li id="goPrev"><a href="javascript:void(0);">&laquo;</a></li>
						    <li id="firstyema" class="active yema"><a href="javascript:void(0);">1</a></li>
		
						    <li id="goNext"><a href="javascript:void(0);">&raquo;</a></li>
					  	  </ul>
					  	</nav>
					 </div>
	    		</div>
	    	</div>
	    	<!-- 右侧列表 -->
	    	<div class="right-ul col-xs-3 center">
    			<div class="right-list">
	    			<div class="center">
			    		<div class="input-group search-input ">
					      <input id="require" type="text"  class="form-control float-r search back-m1 color-w">
					      <span class="input-group-btn search-span">
					        <button class="btn btn-default search-btn" type="button" onclick="search();"></button>
					      </span>
						</div>
						<div class="left table-head color-w">
							<span >序列号</span><span class="float-r">运行状态</span>
						</div>
						<div class="ul-div">
	
							<table id="listtable" class="table table-striped color-w">
							  
							  <tr>
							  	<td class="left"><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413C">0181413C</a></td>
							  	<td class="right">正常</td>
							  </tr>
							  <tr>
							  	<td class="left"><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413C">0181413C</a></td>
							  	<td class="right">正常</td>
							  </tr>
							  <tr>
							  	<td class="left"><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413C">0181413C</a></td>
							  	<td class="right">正常</td>
							  </tr>
							  <tr>
							  	<td class="left"><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413C">0181413C</a></td>
							  	<td class="right">正常</td>
							  </tr>
							  <tr>
							  	<td class="left"><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413C">0181413C</a></td>
							  	<td class="right">正常</td>
							  </tr>
							  <tr>
							  	<td class="left"><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413C">0181413C</a></td>
							  	<td class="right">正常</td>
							  </tr>
							  <tr>
							  	<td class="left"><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413C">0181413C</a></td>
							  	<td class="right">正常</td>
							  </tr>
							  <tr>
							  	<td class="left"><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413C">0181413C</a></td>
							  	<td class="right">正常</td>
							  </tr>
							  <tr>
							  	<td class="left"><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413C">0181413C</a></td>
							  	<td class="right">正常</td>
							  </tr>
							  <tr>
							  	<td class="left"><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413C">0181413C</a></td>
							  	<td class="right">正常</td>
							  </tr>
							  <tr>
							  	<td class="left"><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413C">0181413C</a></td>
							  	<td class="right">正常</td>
							  </tr>
							  <tr>
							  	<td class="left"><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413C">0181413C</a></td>
							  	<td class="right">正常</td>
							  </tr>
							  <tr>
							  	<td class="left"><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413C">0181413C</a></td>
							  	<td class="right">正常</td>
							  </tr>
							  <tr>
							  	<td class="left"><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413C">0181413C</a></td>
							  	<td class="right">正常</td>
							  </tr>
							  
							 
							</table>
						</div>
					</div>
	    		</div>
	    	</div>
	    	
	    	
	    	<!-- 底部表格 -->
	    	<div class="foot-img">
	    		<div class="col-xs-4 margin-t-1 ">
	    			<div class="foot-div1 back-a"> 
	    				<div class="point foot-name ">故障统计</div>
	    				<div class="" style="width: 100%;height:calc(100% - 25px)">
	    				
		    				<div id="echarts3" style="display:inline-block;width: 59%; height: 100%;margin:0"></div>
		    				<div id="faultStatistics" style="display:block;float:right;width: 40%; height: 100%;padding-right:5px">
		    					<span class="color-w">本月故障数：</span><br>
<!-- 		    					<small  style="color:#3399b7">变流器&nbsp;&nbsp;0次</small> -->
<!-- 		    					<div class="progress"> -->
<!-- 		    						<div id="m1w1" class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 10%;"></div> -->
<!-- 								</div> -->
		    					
<!-- 		    					<small style="color:#3399b7">功率模块&nbsp;&nbsp;0次</small> -->
<!-- 		    					<div class="progress"> -->
<!-- 		    						<div id="m1w2" class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 10%;"></div> -->
<!-- 								</div> -->
					
<!-- 		    					<small style="color:#3399b7">控制系统&nbsp;&nbsp;0次</small> -->
<!-- 		    					<div class="progress"> -->
<!-- 		    						<div id="m1w3" class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 10%;"></div> -->
<!-- 								</div> -->
		    				</div>
	    				</div>
	    			</div>
	    		</div>
	    		<div class="col-xs-4 margin-t-1 padding-l">
	    			<div class="foot-div2 back-a"> 
	    				<div class="point foot-name">故障派单</div>
	    				<div class="gzpd">
		    				<div class="gzpd-img"><img src="${path}/resource/images/userphoto.png"></div>
		    				<div class="gzpd-msg"> 
								<div class=''> 
									
									<div>
			    						<span>当前处理人:</span>&nbsp;&nbsp;<span id="repairerName">小华</span>
			    					</div>
			    					<div>							    					
			    						<span>工&nbsp;牌&nbsp;号&nbsp;码:</span>&nbsp;&nbsp;<span id="repairerId">10000</span>
			    					</div>
			    					<div>
			    						<span>联&nbsp;系&nbsp;电&nbsp;话:</span>&nbsp;&nbsp;<span id="repairerPhone">15095808543</span>
			    					</div>
			    					<div>
			    						<span>接&nbsp;单&nbsp;电&nbsp;话:</span>&nbsp;&nbsp;<span id="getTime">2011/12/12</span>
			    					</div>		    				
		    					</div>
		    				</div> 
	    				</div>
	    			</div>
	    		</div>
	    		<div class="col-xs-4 margin-t-1 ">
	    			<div class=" foot-div3 back-a"> 
	    				<div class="point foot-name">对应故障分级的细分故障</div>
	    				<!-- <div id="echarts5" style="width: 100%; height: calc(100% - 25px);">
	    					
	    				</div> -->
	    				<div class="gzjj">
	    					<div class="gzjj-img"><img id="climg" alt="" src="${path}/resource/images/clwc.png"></div>
	    					<div class="gz-msg1">
	    						<div class="fxtime"><span id="fxtime">2017.01.06</span><!-- <br><span>15:35</span> --></div>
	    						<div></div>
	    						<span class="border-top1">发生时间</span>
	    					</div>
	    					<div class="gz-msg2">
	    						<div class="jjtime"><span id="jjtime">2017.01.06</span><!-- <br><span>15:35</span> --></div>
	    						<div></div>
	    						<span class="border-top2">解决时间</span>
	    					</div>
	    					<div class="gz-msg3">
	    						<div class="wcl" id="wcl">100%</div>
	    						<div></div>
	    						<span class="border-top3">完成率</span>
	    					</div>
	    				</div>
	    			</div>
	    		</div>
	    	</div>
    	</div>
    	
    </div>
	<!--弹窗-->
	<div class="layer" style="display: none;">
		<div class="layer-bg">
			<div class="layer-head point foot-name">
				<span>故障波形:</span>
				<a class="off-layer" id="esc">X</a>
			</div> 
			<div  class="layer-body">	
				<div id="showBoEcharts" style="width: 100%; height: 100%;margin:0"></div>
			</div>
		</div>
	</div>



	
</body>
<script type="text/javascript" src="${path}/resource/js/webSocketConf.js"></script>	
<script type="text/javascript">

	//全部设备故障对比
	var totaldata = [];
	var totallegend = [];
	//当前设备故障对比
	var assigndata = [];
	var assignlegend = [];
	//测试故障对比数据
	var testdata = [
		{value:335, name:'测试1'},
        {value:310, name:'测试2'},
        {value:234, name:'测试3'},
        {value:135, name:'测试4'},
        {value:1548, name:'测试5'}
	];
	var testlegend = ['测试1','测试2','测试3','测试4','测试5'];
	
	$(function(){
		$(".img-qbsb").parent().css({"color":"#82d1e8","text-shadow":" 0px 0px 10px #b7d6df"});
		$(".img-qbsb").parent().parent().addClass("dl-active");
		$(".img-qbsb").attr("src","${path}/resource/images/qbsb2.png"); 
		
		$.ajax({
			type : 'POST',
			url : '<%=path%>/manage/errorContentLast',
			data : {
				serialNum : '${serialNum}'
			},
			dataType : 'json',
			async : false,
			success : function(result) {
				if(result.status == 'OK') {
					initbottom2(result.data.id);
				} else {
					//alert("系统错误！");
				}
			},
			error : function() {
				//alert("系统错误！");
			}
		});
// 		$.ajax({
// 			type : 'POST',
<%-- 			url : '<%=path%>/manage/chtctrupdate', --%>
// 			data : {
// 				serialNum : '${serialNum}',
// 				lowerTime : '',
// 				upperTime : ''
// 			},
// 			dataType : 'json',
// 			async : false,
// 			success : function(result) {
// 				console.log(result);
// 				if(result.status == 'OK') {
// 					var total = eval("(" + result.data.total + ")");
// 					var assign = eval("(" + result.data.assign + ")");
// 					$.each(total, function(i) {
// 						totaldata.push({
// 							name : total[i].name,
// 							value : total[i].count
// 						});
// 						totallegend.push(total[i].name);
// 					});
// 					initPieDoughnut("echarts2",totallegend,totaldata);
					
// 					$.each(assign, function(i) {
// 						assigndata.push({
// 							name : assign[i].name,
// 							value : assign[i].count
// 						});
// 						assignlegend.push(assign[i].name);
// 					});
// 					initPieDoughnut("echarts1",assignlegend,assigndata);
// 				} else {
// 					//alert("系统错误！");
// 					initPieDoughnut("echarts1",testlegend,testdata);
// 					initPieDoughnut("echarts2",testlegend,testdata);
// 				}
// 			},
// 			error : function() {
// 				//alert("系统错误！");
// 				initPieDoughnut("echarts1",testlegend,testdata);
// 				initPieDoughnut("echarts2",testlegend,testdata);
// 			}
// 		});
		
		//test环境
		//search();
		
		//加载历史故障列表
		attrYemaInitList();
		
// 		$.ajax({
// 			type : 'POST',
<%-- 			url : '<%=path%>/manage/errorCountByMonthWithSerialNum', --%>
// 			data : {
// 				serialNum : '${serialNum}'
// 			},
// 			dataType : 'json',
// 			async : false,
// 			success : function(result) {
// 				console.log(result);
// 				if(result.status == 'OK') {
// 					var errorCountData = []; var errorCountlegendData = [];
// 					$.each(result.data, function(i) {
// 						errorCountData.push({
// 							value : result.data[i].count, 
// 							name : result.data[i].month
// 						});
// 						errorCountlegendData.push(result.data[i].month);
// 					});
// 					myEcharts3.setOption({
// 						legend: {
// 					        data : errorCountlegendData
// 					    },
// 					    series: [{
// 					    	data : errorCountData
// 					    }]
// 		        	})
// 				} else {
// 					//alert("系统错误！");
// 				}
// 			},
// 			error : function() {
// 				//alert("系统错误！");
// 			}
// 		});
		
		$.ajax({
			type : 'POST',
			url : '<%=path%>/manage/errorCountByType',
			data : {
				serialNum : '${serialNum}'
			},
			dataType : 'json',
			async : false,
			success : function(result) {
				if(result.status == 'OK') {
					//var yData = []; 
					var Data = []; var countsum = 0;
					var htmlarr = [];
					
					$.each(result.data, function(i) {
						//yData.push(result.data[i].faultType);
						//Data.push(result.data[i].count);
						if(result.data[i].count > 0) {
							Data.push({
								value: result.data[i].count,
								name: result.data[i].faultType
							});
							countsum += result.data[i].count;
							
							var htmlobj = {faultType:'',count:0};
							htmlobj.faultType = result.data[i].faultType;
							htmlobj.count = result.data[i].count;
							htmlarr.push(htmlobj);
						}
					});
					var html = '<span class="color-w">本月故障数：</span><br>';
					$.each(htmlarr, function(i) {
						html += '<small style="color:#3399b7" class="">'+htmlarr[i].faultType+'&nbsp;&nbsp;'+htmlarr[i].count+'次</small>'+
						'<div class="progress">'+
						'<div class="progress-bar" role="progressbar" '+
						'aria-valuenow="'+htmlarr[i].count+'" aria-valuemin="0" '+
						'aria-valuemax="'+countsum+'" style="width: '+100*htmlarr[i].count/countsum+'%;">'+
						'</div></div>';
					});
					
					myEcharts3.setOption({
						title: {text: '共计：'+countsum+'次'},
						series: [{data: Data}]
					});
					
					$("#faultStatistics").html(html);
					
					//initFaultType(yData, Data);
				} else {
					//alert("系统错误！");
				}
			},
			error : function() {
				//alert("系统错误！");
			}
		});
	})
	function initbottom2(faultId) {
		if(faultId != null && faultId != undefined && faultId != '0') {
			$.ajax({
				type : 'POST',
				url : '<%=path%>/manage/maintainPostByFaultId',
				data : {
					faultId : faultId
				},
				dataType : 'json',
				async : false,
				success : function(result) {
					if(result.status == 'OK') {
						var data = result.data;
						$('#repairerName').text(data.repairerName);
						$('#repairerId').text(data.repairerId);
						$('#repairerPhone').text(data.repairerPhone);
						$('#getTime').text(data.getTime);
						
						$('#fxtime').text(data.startTime);
						$('#jjtime').text(data.endTime);
						if(data.endTime == '') {
							$('#wcl').html("进行中...");
							$('#climg').attr("src","${path}/resource/images/clz.png");
						}
					} else {
						//alert("系统错误！");
					}
				},
				error : function() {
					//alert("系统错误！");
				}
			});
		} else {
			alert(faultId);
		}
	}
//加载历史故障列表
var size = 1;
var curPageNO = 1;
function initList() {
	$.ajax({
		type : 'POST',
		url : '<%=path%>/manage/errorListWithSerialNum',
		data : {
			serialNum : '${serialNum}',
			pageSize : 8,
			curPageNO : curPageNO
		},
		dataType : 'json',
		async : false,
		success : function(result) {
			if(result.status == "OK") {
				$('#hisErrorList').text('');
				var html = "<tr><th>序号</th><th>故障时间</th><th>故障代码</th><th>故障描述</th><th>故障录波</th></tr>";
				if(result.data.list == "[null]") {
					html += '<tr><td colspan="5" style="text-align: center">暂无数据</td></tr>';
				} else {
					console.log(result.data.list);
					size = result.data.size;
					var list = eval("(" + result.data.list + ")");
					$.each(list, function(i){
						html += '<tr><td>'+list[i].id +
								'</td><td>'+list[i].startTime +
								'</td><td>'+list[i].faultCode +
								'</td><td>'+list[i].faultName +'</td>'+
								'<td><button onClick="showBo(\''+list[i].id+'\',\''+list[i].dsp+'\');">查看</button>'+
								'<a  class="btn-a" href="http://218.75.205.176:60606/airconditionsystem/dataapi/errorFileById?id='+list[i].id +'">下载</a></td></tr>';
					});
				}
				$('#hisErrorList').append(html);
			}
		},
		error : function() {
			//alert("系统错误！");
		}
	})
}
//点击页码
function attrYemaInitList() {
	curPageNO = 1;
	initList();
	//$('.pagination').html('');
	$('.pagination').html('<li id="goPrev"><a href="javascript:void(0);">&laquo;</a></li>'+
	    '<li id="firstyema" class="active yema"><a href="javascript:void(0);">1</a></li>'+
	    '<li id="goNext"><a href="javascript:void(0);">&raquo;</a></li>');
	if(size > 8) {
		var html = '';
		var yemaToal = (size/8)+1;
		for(var i=2; i<yemaToal; i++) {
			html += '<li class="yema"><a href="javascript:void(0);">'+i+'</a></li>'
		}
		$('#firstyema').after(html);
	}
	attrYeMa();
}
function attrYeMa() {
	$('.yema').click(function() {
		console.log("a");
		$('.yema').removeClass("active");
		$(this).addClass("active");
		curPageNO = $(this).children('a').text();
		initList();
	});
	$('#goPrev').click(function() {
		var prevyema = $(this).nextAll('.active').prev('.yema');
		if(prevyema != null && prevyema.length > 0) {
			$(this).nextAll('.active').removeClass("active");
			prevyema.addClass("active");
			curPageNO = prevyema.children('a').text();
			initList();
		}
	});
	$('#goNext').click(function() {
		var nextyema = $(this).prevAll('.active').next('.yema');
		if(nextyema != null && nextyema.length > 0) {
			$(this).prevAll('.active').removeClass("active");
			nextyema.addClass("active");
			curPageNO = nextyema.children('a').text();
			initList();
		}
	});
}
	
var f0 = [597,  596,  598,  598,  595,  598,  600,  599,  599,  602,  597,  600,  598,  599,  600,  600,  600,  599,  600,  604,  603];
var f1 = [65042,64790,64895,64857,65033,65063,65154,65393,65535,270,  242,  523,  526,  728,  643,  686,  512,  491,  385,  111,  21];
var f2 = [1,    258,  256,  505,  479,  726,  603,  653,  483,  460,  361,  133,  65505,65284,65272,64993,65092,64800,64908,64874,65039];
var f3 = [9090, 9090, 9090, 9090, 9090, 9090, 9090, 9090, 9090, 9090, 9090, 9090, 9090, 9090, 9090, 9090, 9090, 9090, 9090, 9090, 9090];
var f4 = [1,    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,    1];
var f5 = [7,    7,    8,    8,    9,    9,    10,   10,   11,   11,   0,    0,    1,    1,    2,    2,    3,    3,    4,    4,    5];
var f6 = [5,    5,    5,    5,    5,    5,    5,    5,    5,    5,    5,    5,    5,    5,    5,    5,    5,    5,    5,    5,    5];


var showBoOption = {
    tooltip : {
        trigger: 'axis'
    },
    legend: {
        data:['A相电流','B相电流','上位机启动命令','上位机转速','中间电压','定时器存活状态','校验常数','调制发送矢量编号','调制模式','调制深度']
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis : [
        {
            type : 'category',
            boundaryGap : false,
            data : []
        }
    ],
    yAxis : [
        {
            type : 'value'
        }
    ],
    dataZoom: [{
        //type: 'inside',
        show : true,
        height : 12,
        start: 49.9,
        end: 50,
        bottom : '0%',
        textStyle : {
        	color : '#fff'
        }
    },{
        type: 'inside',
        start: 47,
        end: 52
    }],
    series : [
        {
            name:'A相电流',
            type:'line',
            smooth: true,
            data:[]
        },
        {
            name:'B相电流',
            type:'line',
            smooth: true,
            data:[]
        },
        {
            name:'上位机启动命令',
            type:'line',
            smooth: true,
            data:[]
        },
        {
            name:'上位机转速',
            type:'line',
            smooth: true,
            data:[]
        },
        {
            name:'中间电压',
            type:'line',
            smooth: true,
            data:[]
        },
        {
            name:'定时器存活状态',
            type:'line',
            smooth: true,
            data:[]
        },
        {
            name:'校验常数',
            type:'line',
            smooth: true,
            data:[]
        },
        {
            name:'调制发送矢量编号',
            type:'line',
            smooth: true,
            data:[]
        },
        {
            name:'调制模式',
            type:'line',
            smooth: true,
            data:[]
        },
        {
            name:'调制深度',
            type:'line',
            smooth: true,
            data:[]
        }
        
    ]
};

$("#esc").click(function(){
	$(".layer").hide();
})
//展示波形图
function showBo(id, dsp) {
	$(".layer").show();
	
	var showBoEcharts = echarts.init(document.getElementById("showBoEcharts"));
	
	$.ajax({
		type : 'POST',
		url : '<%=path%>/manage/errorDataById',
		data : {
			id : id,
			dsp : dsp
		},
		dataType : 'json',
		async : false,
		success : function(result) {
			if(result.status == 'OK') {
				console.log("showbo",result.data);
				showBoOption.series[0].data = result.data["A相电流"];
				showBoOption.series[1].data = result.data["B相电流"];
				showBoOption.series[2].data = result.data["上位机启动命令"];
				showBoOption.series[3].data = result.data["上位机转速"];
				showBoOption.series[4].data = result.data["中间电压"];
				showBoOption.series[5].data = result.data["定时器存活状态"];
				showBoOption.series[6].data = result.data["校验常数"];
				showBoOption.series[7].data = result.data["调制发送矢量编号"];
				showBoOption.series[8].data = result.data["调制模式"];
				showBoOption.series[9].data = result.data["调制深度"];
				
				showBoEcharts.setOption(showBoOption);
			} else {
				//alert("系统错误！");
			}
		},
		error : function() {
			//alert("系统错误！");
		}
	});
}
	
	
	//加载右侧列表
	function search() {
		$.ajax({
			type : 'POST',
			url : '<%=path%>/manage/seconddevTotal',
			data : {
				livedata : livedata,
				require : $("#require").val()
			},
			dataType : 'json',
			async : false,
			success : function(result) {
				if(result.status == "OK") {
					$('#listtable').text('');
					//var html = "<tr><th>变频器序列号</th><th>安装位置</th><th>投运时间</th><th>工作状态</th></tr>";
					var html = "";
					$.each(result.data, function(i){
						var href = "<%=path%>/manage/redirect/allEquip/nowEquip?serialNum="+result.data[i].serialNum;
						html += '<tr><td class="left"><a href='+href+'>'+result.data[i].serialNum +
								'</a></td><td class="right">'+result.data[i].state +'</td></tr>';
					});
					$('#listtable').append(html);
				}
			},
			error : function() {
				//alert("系统错误！");
			}
		})
	}
	
	/**加载环形饼图*/
	function initPieDoughnut(domId,legend,data) {
		var pieDoughnut = echarts.init(document.getElementById(domId));
		pieDoughnut.setOption({
			tooltip: {
		        trigger: 'item',
		        formatter: "{a} <br/>{b}: {c} ({d}%)"
		    },
		    legend: {
		        orient: 'vertical',
		        x: 'left',
		        y: 'bottom',
		        data:legend
		    },
		    series: [
		             {
		                 name:'故障分析',
		                 type:'pie',
		                 radius: ['50%', '70%'],       //内环半径，外环半径
		                 avoidLabelOverlap: false,
		                 label: {
		                     normal: {
		                         show: false,
		                         position: 'center'
		                     },
		                     emphasis: {
		                         show: true,
		                         textStyle: {
		                             fontSize: '30',
		                             fontWeight: 'bold'
		                         }
		                     }
		                 },
		                 labelLine: {
		                     normal: {
		                         show: false
		                     }
		                 },
		                 data:data
		             }
		         ]
		});
	}

	var myEcharts3 = echarts.init(document.getElementById("echarts3"));
	myEcharts3.setOption({
	    title: {
	    	
	        text: '共计：0次',
	        left: 'left',
	        bottom: 'bottom',
	        textStyle: {
	            color: '#fff',
	            fontSize: '12'
	        }
	    },
	    series : [
	        {
	            name: '故障统计',
	            type: 'pie',
	            color: ['#3399b7','#73cc4e','#16d8d7',],
	            radius: '55%',
	            center: ['50%', '50%'],
	            data: [].sort(function (a, b) { return a.value - b.value}),
	            //roseType: 'radius', //通过半径区分数据大小'radius' 面积展现数据的百分比，半径展现数据的大小。'area' 所有扇区面积相同，仅通过半径展现数据大小。
	            label: {
	                normal: {
	                	formatter: '{d}% \n{b}',
	                	textStyle: {
	                		fontSize: 10
	                	}
	                }
	            },
	            labelLine: {
	                normal: {
	                    lineStyle: {
	                        color: '#fff'
	                    },
	                    //smooth: 0.2,//可以设置成 true 平滑显示，也可以设置为 0 到 1 的值，表示平滑程度。
	                    length: 8,
	                    length2: 5
	                }
	            },
	            animationType: 'scale',
	            animationEasing: 'elasticOut',
	            animationDelay: function (idx) {
	                return Math.random() * 200;
	            }
	        }
	    ]
	});
// 	var myEcharts3 = echarts.init(document.getElementById("echarts3"));
// 	myEcharts3.setOption({
// 		title: {
// 	        text: '故障次数',
// 	    },
// 		tooltip: {
// 	        trigger: 'item',
// 	        formatter: "{a} <br/>{b}: {c} ({d}%)"
// 	    },
// 	    legend: {
// 	        orient: 'vertical',
// 	        x: 'right',
// 	        y: 'bottom',
// 	        data:['2016-06','2016-07','2016-08','2016-09']
// 	    },
// 	    series: [
// 	             {
// 	                 name:'故障分析',
// 	                 type:'pie',
// 	                 radius: ['50%', '70%'], //内环半径，外环半径
// 	                 clockwise: false,
// 	                 avoidLabelOverlap: false,

// 	                 label: {
// 	                     normal: { show: false, position: 'center' },
// 	                     emphasis: {
// 	                         show: true,
// 	                         textStyle: { fontSize: '30', fontWeight: 'bold' }
// 	                     }
// 	                 },
// 	                 labelLine: {
// 	                     normal: { show: false }
// 	                 },
// 	                 data:[
// 	                     {value:13, name:'2016-06'},
// 	                     {value:31, name:'2016-07'},
// 	                     {value:11, name:'2016-08'},
// 	                     {value:23, name:'2016-09'}
// 	                 ]
// 	             }
// 	         ]
// 	});
// 	myEcharts3.setOption({
// 		title: {
// 	        text: '对比参数曲线',
// 	    },
// 	    tooltip: {
// 	    	x:'right',
// 	        trigger: 'axis'
// 	    },
// 	    legend: {
// 	        data:['红色','绿色']
// 	    },
	    
// 	    xAxis:  {
// 	        type: 'category',
// 	        boundaryGap: false,
// 	        data: ['00:00','01:00','02:00','03:00','04:00','05:00','06:00','07:00','08:00','09:00','10:00']
// 	    },
// 	    yAxis: {
// 	        type: 'value',
// 	        data:[0,100,200,300]
// 	    },
// 	    series: [
// 	             {
// 	                 name:'红色',
// 	                 type:'line',
// 	                 data:[200,180,220, 210, 224, 215, 150,215,280,200,220],
	             
// 	             },
// 	             {
// 	                 name:'绿色',
// 	                 type:'line',
// 	                 data:[100,90, 120,50, 40,70, 70, 40,30,120,90],
	               
// 	             }
// 	         ]
	    
// 	});
	
// 	var myEcharts4 = echarts.init(document.getElementById("echarts4"));
// 	myEcharts4.setOption({
// 		title: {
// 	        text: '设备故障统计',
// 	    },
// 	    tooltip: {
// 	        trigger: 'axis',
// 	        axisPointer: {
// 	            type: 'shadow'
// 	        }
// 	    },
// 	    grid : {
// 	    	top : '20%',
// 	    	bottom : '20%',
// 	    	left:'25%'
// 	    },
// 	    xAxis: {
// 	        type: 'value',
// 	        boundaryGap: [0, 0.01]
// 	    },
// 	    yAxis: {
// 	        type: 'category',
// 	        axisLabel : {
// 	        	textStyle : {
// 	        		fontSize : 14
// 	        	}
// 	        },
// 	        data: ['系统级','模块级','控制级']
// 	    },
// 	    series: [
// 	             {
// 	                 type:'bar',
// 	                 data:[33,75,150],
// 	             	 barWidth:10
// 	             },
// 	     ]
// 	});
	function initFaultType(yData, Data) {
		myEcharts4.setOption({
			yAxis: { data: yData },
		    series: [ {data : Data } ]
		});
		myEcharts4.on('click', function (params) {
		    if (params.componentType === 'series') {
		        if (params.seriesType === 'bar') {
		        	$.ajax({
		    			type : 'POST',
		    			url : '<%=path%>/manage/errorCountByLevel',
		    			data : {
		     				serialNum : '${serialNum}',
		     				faultType : params.name
		    			},
		    			dataType : 'json',
		    			async : false,
		    			success : function(result) {
		    				if(result.status == 'OK') {
		    					var levelData = []; var legendData = [];
		    					$.each(result.data, function(i) {
		    						levelData.push({
		    							value : result.data[i].count, 
		    							name : result.data[i].faultLevel
		    						});
		    						legendData.push(result.data[i].faultLevel);
		    					});
		    					myEcharts5.setOption({
		    		        		title : {
		    		        			text : params.name + '故障分类信息'
		    		        		},
		    		        		legend: {
			    				        data : legendData
			    				    },
			    				    series: [{
			    				    	data : levelData
			    				    }]
		    		        	})
		    					
		    				} else {
		    					//alert("系统错误！");
		    				}
		    			},
		    			error : function() {
		    				//alert("系统错误！");
		    			}
		    		});
		        }
		    }
		});
	}
	
// 	var myEcharts5 = echarts.init(document.getElementById("echarts5"));
// 	myEcharts5.setOption({
// 			title: {
// 		        text: '二级故障统计',
// 		    },
// 			xAxis: {
// 		        type: 'category',
// 		        boundaryGap: false,
// 		        data: ['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15']
// 		    },
// 		    yAxis: {
// 		        type: 'value',
// 		    },
// 		    series: [
// 		             {
// 		                 name:'红色',
// 		                 type:'line',
// 		                 smooth: true,
// 		                 data:[200,180,220, 210, 224, 215, 150,215,280,200,220,110,120,110,200],
		             
// 		             },
// 		     ]
// 	});
// 	myEcharts5.setOption({
// 		title: {
// 	        text: '故障分类信息',
// 	    },
// 		tooltip: {
// 	        trigger: 'item',
// 	        formatter: "{a} <br/>{b}: {c} ({d}%)"
// 	    },
// 	    legend: {
// 	        orient: 'vertical',
// 	        x: 'right',
// 	        y: 'bottom',
// 	        data:['chrome','firefox','Safari']
// 	    },
// 	    series: [
// 	             {
// 	                 name:'故障分析',
// 	                 type:'pie',
// 	                 radius: ['50%', '70%'],       //内环半径，外环半径
// 	                 clockwise: false,
// 	                 avoidLabelOverlap: false,

// 	                 label: {
// 	                     normal: {
// 	                         show: false,
// 	                         position: 'center'
// 	                     },
// 	                     emphasis: {
// 	                         show: true,
// 	                         textStyle: {
// 	                             fontSize: '30',
// 	                             fontWeight: 'bold'
// 	                         }
// 	                     }
// 	                 },
// 	                 labelLine: {
// 	                     normal: {
// 	                         show: false
// 	                     }
// 	                 },
// 	                 data:[
// 	                     {value:1335, name:'chrome'},
// 	                     {value:310, name:'firefox'},
// 	                     {value:234, name:'Safari'},
	                    
// 	                 ]
// 	             }
// 	         ]
		
// 	});
	
//获取设备列表实时数据
	
	var webSocket2 = null;
    var livedata;
    if ("WebSocket" in window) {
		webSocket2 = new WebSocket(webSocketUrl);
		console.log("建立实时连接！");
	} else if ("MozWebSocket" in window) {
		webSocket2 = new MozWebSocket(webSocketUrl);
		console.log("建立实时连接！");
	} else {
		alert("浏览器不支持！");
	}
	webSocket2.onerror = function() {
		alert("无法建立实时连接！");
	};
	webSocket2.onopen = function(event) {
		send2();
		console.log("open");
	};
	webSocket2.onmessage = function() {
		if(event.data.length>2){
			livedata=event.data;
			//tableinitinfo();
			search();
			webSocket2.close();
		}else{
			console.log("resend...");
			send2();
		}		
	};
	webSocket2.onclose = function() {
	};
	window.onbeforeunload = function() {
		webSocket2.close();
	};
	function send2(){    //Websocket接口
	    console.log("send");
// 	    var message = "[{\"serialnum\":\"all\",\"signalnames\":[\"breakerstate\",\"runninglight\",\"faultlight\"]}]";//调用参数
	    var message = "[{\"serialnum\":\"all\",\"signalnames\":[\"c196\",\"c78\",\"c77\"]}]";//调用参数
	    webSocket2.send(message);
	}
	/*改变进度条颜色*/
	$(function(){
		$("body").find(".progress").eq(1).css("border","1px solid #73cc4e");
		$("body").find(".progress").eq(1).children(".progress-bar").css("background","#73cc4e");
		$("body").find(".progress").eq(1).prev().css("color","#73cc4e");
		$("body").find(".progress").eq(2).css("border","1px solid #16d8d7");
		$("body").find(".progress").eq(2).children(".progress-bar").css("background","#16d8d7");
		$("body").find(".progress").eq(2).prev().css("color","#16d8d7");
	})
</script>
</html>
